<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<!--标准mui.css-->
		<link rel="stylesheet" href="../css/mui.min.css">
		<link rel="stylesheet" href="../css/iconfont.css">
		<link rel="stylesheet" href="../css/app.css"/>
		<style>
			.mui-content .mui-table-view-cell .iconfont{
				font-size: 20px;
				padding-right:20px;
			}
			.mui-table-view-cell:after{
				/*left:0px;*/
			}
			.mui-content .icon-shezhi{
				color:#999;
			}
			.mui-content .icon-shoucang{
				color:#fea93d;
			}
			.mui-content .icon-2{
				color:#FF0000;
			}
			.mui-content .icon-pinglun{
				color:#8A6DE9;
			}
			.am-header .mui-header-img img{
				width:80px;
				height:80px;
				border-radius: 40px;
			}
			.am-header{
				text-align: center;
				padding:40px 30px;
				background:#fff;
				display: none;
			}
			.mui-header-show{
				display: block;
			}
			.mui-header-img,.mui-header-name{
				display: inline-block;
			}
			.mui-table-view{
				background: none;
				margin-top:5px!important;
			}
			.mui-table-view:before,.mui-table-view:after,.mui-table-dingdan:after{
				content:none;
			}
			.mui-table-view-cell{
				background: #fff;
			}
			.mui-table-view-shezhi,.mui-table-view-version{
				margin-top:5px;
			}
			.mui-table-view-version:after{
				content: none;
			}
			.mui-icon{
				font-size:14px;
				color: #ACACB4;
			}
			.mui-header-name{
				margin-top:10px;
			}
			.mui-head-top{
				display: inline-block;
			}
		</style>
	</head>

	<body>
		<div class="am-header">
			<div class="mui-head-top mui-head-top1">
				<div class="mui-header-img">
					<img src="../images/default.png" id="mui_header_img" />
				</div>
				<div></div>
				<div class="mui-header-name"><span id="mui_header_name">我的橄榄app</span><span class="mui-icon mui-icon-forward"></span></div>
			</div>
		</div>
		<div class="am-header">
			<div class="mui-head-top mui-head-top2">
				<div class="mui-header-img">
					<img src="../images/default.png" />
				</div>
				<div></div>
				<div class="mui-header-name">未登录<span class="mui-icon mui-icon-forward"></span></div>
			</div>
		</div>
		<div class="mui-content">
			<ul class="mui-table-view">
		        <li class="mui-table-view-cell mui-table-favorites">
		            <a class="mui-navigate-right">
						<i class="iconfont icon-shoucang"></i>我的收藏
		            </a>
		        </li>
		        <li class="mui-table-view-cell mui-table-news">
		            <a class="mui-navigate-right">
						<i class="iconfont icon-pinglun"></i>消息通知
		            </a>
		        </li>
		        <li class="mui-table-view-cell mui-table-dingdan">
		            <a class="mui-navigate-right">
						<i class="iconfont icon-2"></i>我的订单
		            </a>
		        </li>
		        <!--<li class="mui-table-view-cell">
		            <a class="mui-navigate-right">
						<i class="iconfont icon-pinglun"></i>我的评论
		            </a>
		        </li>-->
		        <li class="mui-table-view-cell mui-table-view-version" id="mui-table-view-version">
		            <a class="mui-navigate-right">
						<i class="iconfont icon-version"></i>版本更新
		            </a>
		        </li>
		        <li class="mui-table-view-cell mui-table-view-shezhi">
		            <a class="mui-navigate-right">
						<i class="iconfont icon-shezhi"></i>设置
		            </a>
		        </li>
		    </ul>
		</div>

	</body>

	<script src="../js/mui.min.js"></script>
	<script src="../js/castapp.js"></script>
	<script src="../js/myapp.js"></script>
	<script>
		ca.init();
//		console.log(localStorage.getItem('user_avatar'));
//		localStorage.clear();
		//检测版本
		ca.id('mui-table-view-version').addEventListener('tap',function(){
			var version = ca.getOs('version');
			var access_token = localStorage.getItem('access_token');
			ca.get({
				url:request_url+'/api/public/check_version',
				data:{
					access_token:access_token,
					version:version
				},
				succFn:function(res){
					console.log(res);
					var json = JSON.parse(res);
					if(json.status == 1){
						ca.confirm({
							title:'提示',
							content:'是否升级到 '+json.version+' 版本',
							callback:function(data){
								if(data){
									ca.prompt('正在下载');
								}
							}
						});
					}
					else{
						ca.alert({
							title:'提示',
							content:'已是最新版本:'+version+',无需更新!',
							callback:function(){}
						});//ca.prompt('已是最新版本:'+version+',无需更新!'); 
					}
				}
			});
		});
		//修改信息
		ca.className('mui-head-top1')[0].addEventListener('tap',function(){
			ca.newInterface({url:'info.html',id:"info"});
		});
		//我的收藏
		ca.className('mui-table-favorites')[0].addEventListener('tap',function(){
			ca.newInterface({url:'my_favorites.html',id:"my_favorites"});
		});
		//我的收藏
		ca.className('mui-table-news')[0].addEventListener('tap',function(){
			ca.newInterface({url:'my_news.html',id:"my_news"});
		});
		//去登录
		ca.className('mui-head-top2')[0].addEventListener('tap',function(){
			ca.newInterface({url:'login.html',id:"info"});
		});
		//设置
		ca.className('mui-table-view-shezhi')[0].addEventListener('tap',function(){
			ca.newInterface({url:'setting.html',id:"info"});
		});
		//我的订单  
		ca.className('mui-table-dingdan')[0].addEventListener('tap',function(){
			ca.newInterface({url:'my_order.html',id:"my_order"});
		});
		init_home();
		//接收通知消息    
		ca.receiveNotice('userInfo',function(event){
			if(typeof(event.detail.mobile) != 'undefined' && event.detail.mobile){
				ca.id('mui_header_img').src = localStorage.getItem('user_avatar');
				ca.id('mui_header_name').innerText = localStorage.getItem('user_nicename');
				//默认未登录
				var am_header = ca.className('am-header');
				obj = am_header[0];
				//先删除class
				removeClass(am_header[0],'mui-header-show');
				removeClass(am_header[1],'mui-header-show');
				//后添加class
				addClass(obj,'mui-header-show');
			}
			else{
				init_home();	
			}
		});
	</script>
</html>